<?php
class Zenddn_Plugin_Language extends Zend_Controller_Plugin_Abstract{
    
    public function preDispatch(Zend_Controller_Request_Abstract $request){
        $module = $request->getModuleName();
        $controller = $request->getControllerName();
        $locale = Zend_Registry::get('locale');
        
        $file = APPLICATION_PATH . "/languages/$module/$locale/$controller/lang.csv";
        $fileSystem = APPLICATION_PATH . "/languages/$module/$locale/lang.csv";
        
        $option = array('adapter' => 'csv',
                        'content' => $file,
                        'locale' => $locale,
                        'delimiter' => '=');
                        
    	$translate = new Zend_Translate($option);
        $translate->addTranslation(array('content' => $fileSystem, 'locale' => $locale));
        $translate->setLocale($locale);
        
        Zend_Registry::set('Zend_Translate', $translate);
    }
}